home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1997 May
/
EnigmA AMIGA RUN 18 (1997)(G.R. Edizioni)(IT)[!][issue 1997-05][EAR-CD II].iso
/
softwareupdate
/
system
/
amigados
/
parsingcommandline
/
example7.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-10-10
|
4KB
|
120 lines
/***********************************************************/
/* */
/* Amiga C Encyclopedia (ACE) Amiga C Club (ACC) */
/* -------------------------- ------------------ */
/* */
/* Manual: AmigaDOS Amiga C Club */
/* Chapter: Parsing Command Line Tulevagen 22 */
/* File: Example7.c 181 41 LIDINGO */
/* Author: Anders Bjerin SWEDEN */
/* Date: 93-03-06 */
/* Version: 1.0 */
/* */
/* Copyright 1993, Anders Bjerin - Amiga C Club (ACC) */
/* */
/* Registered members may use this program freely in their */
/* own commercial/noncommercial programs/articles. */
/* */
/***********************************************************/
/* This example demonstrates how to use the FindArg() function. */
/* We simply use it to scan the command line template and return */
/* the position of each command template. */
/* Include the dos library definitions: */
#include <dos/dos.h>
/* Include information about the argument parsing routine: */
#include <dos/rdargs.h>
/* Now we include the necessary function prototype files: */
#include <clib/dos_protos.h> /* General dos functions... */
#include <clib/exec_protos.h> /* System functions... */
#include <stdio.h> /* Std functions [printf()...] */
#include <stdlib.h> /* Std functions [exit()...] */
/* Here is our command line template: (Note that it consists of */
/* three command templates. First we have the "SoundFile/A" which */
/* has the position 0, then the "V=Volume/K/N" which has position */
/* 1, and finally the "F=Filter/S" which has the position 2.) */
#define MY_COMMAND_LINE_TEMPLATE "SoundFile/A,V=Volume/K/N,F=Filter/S"
/* Set name and version number: */
UBYTE *version = "$VER: AmigaDOS/ParsingCommandLine/Example7 1.0";
/* Declare an external global library pointer to the Dos library: */
extern struct DosLibrary *DOSBase;
/* Declared our own functions: */
/* Our main function: */
int main( int argc, char *argv[] );
/* Main function: */
int main( int argc, char *argv[] )
{
/* Store the command template position here: */
int template_position;
/* We need dos library version 37 or higher: */
if( DOSBase->dl_lib.lib_Version < 37 )
{
/* Inform the user: */
printf( "This program needs Dos Library V37 or higher!\n" );
/* Exit with an error code: */
exit( 20 );
}
/* Print heading: */
printf( "Command Template Position\n" );
printf( "--------------------------\n" );
/* Which position has the comman template "SoundFile"? */
template_position = FindArg( MY_COMMAND_LINE_TEMPLATE, "SoundFile" );
/* Print the position: */
printf( "SoundFile %d\n", template_position );
/* Which position has the comman template "Filter"? */
template_position = FindArg( MY_COMMAND_LINE_TEMPLATE, "Filter" );
/* Print the position: */
printf( "Filter %d\n", template_position );
/* Which position has the comman template "Volume"? */
template_position = FindArg( MY_COMMAND_LINE_TEMPLATE, "Volume" );
/* Print the position: */
printf( "Volume %d\n", template_position );
/* The End! */
exit( 0 );
}